/*###################################################################*
#
# MPGL Engine - CrossPlatform OpenGL Engine
# Copyright (C) 2013  Mitchell Pell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################*/

#ifndef GL_BUTTON_EVENT_H
#define GL_BUTTON_EVENT_H

#include "../../../Base/Event.h"
#include <GLFW/glfw3.h>
#include <boost/shared_ptr.hpp>

namespace mp_gl
{
	using namespace mp_base;

	enum GLButtonPressType : int
	{
		BTN_UP = GLFW_RELEASE,
		BTN_DOWN = GLFW_PRESS,
		BTN_PRESS = 2,
		BTN_RELEASE = 3,
		BTN_HELD = 4,
		
	};

	/*!----------------------------------------------------------------
	*	@class		GLButtonEvent
	*	@brief		Event used for binding and passing button
	*				press events for the mouse and keyboard.
	*
	*	@author		Mitchell Pell
	*	@date		9/27/2013
	*	@version	1.0
	*
	-----------------------------------------------------------------*/
	class GLButtonEvent : public Event
	{
	protected:
		GLButtonPressType	m_pressTrigger;	//Input event press type
		GLButtonPressType	m_currentPressType;
		GLButtonPressType	m_prevPressType;//Last event press type
		double			m_timeSpan;			//Total Elapsed Time
		double			m_lastTimeStamp;	//Time of last update
		double			m_repeatTriggerTime;//Time held to trigger
	public:
		GLButtonEvent();
		virtual ~GLButtonEvent(){}

		virtual void Update(GLFWwindow* window);
		void Reset(){m_timeSpan = m_lastTimeStamp = 0.0;}

		void SetPressType(GLButtonPressType pressType)
			{ m_pressTrigger = pressType; }
		GLButtonPressType PressType()
			{return m_pressTrigger;}

		void setHoldLength(double holdTime )
			{ m_repeatTriggerTime = holdTime; }
		double HoldTime(){return m_repeatTriggerTime;}

		bool IsTriggered();
	};

	typedef boost::shared_ptr<GLButtonEvent> spGLButtonEvent;
}

#endif